//package com.ocom.mqsimple.business.xcx.kitchenprinter;
//
//import com.alibaba.fastjson.JSON;
//import com.ocom.common.enums.ssgl.SSGLMqTypeEnum;
//import com.ocom.common.request.simple.ssgl.SSGLAccessRecordRequest;
//import com.ocom.common.request.simple.ssgl.SSGLMqBaseRequest;
//import com.ocom.common.request.simple.ssgl.SSGLNewPersonInfoRequest;
//import com.ocom.mqsimple.config.KitchenPrinterMqConfig;
//import com.ocom.mqsimple.config.SSGLMqConfig;
//import com.ocom.mqsimple.feign.ExposeClientService;
//import com.ocom.redis.util.RedisUtil;
//import com.rabbitmq.client.Channel;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.amqp.core.Message;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.messaging.handler.annotation.Headers;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.nio.charset.StandardCharsets;
//import java.util.Map;
//
//
//@Component
//public class KitchenPrinterConsumerMqListener {
//
//	private Logger logger = LoggerFactory.getLogger(KitchenPrinterConsumerMqListener.class);
//
//	@Autowired
//	ExposeClientService exposeClientService;
//
//	@Resource
//	RedisUtil redisUtil;
//
//
//	/**
//	 * 把该监听命名为A监听
//	 * 监听队列  远程服务支付接口发送消息  该队列会接受
//	 * [message, headers, channel]
//	 * @return {@link }
//	 * @throws
//	 */
//	@RabbitListener(queues = KitchenPrinterMqConfig.KITCHENPRINTER_QUEUE)
//	public void process(Message message, @Headers Map<String, Object> headers, Channel channel) throws Exception {
//		logger.info("message【{}】",message);
//		String processMessage = new String(message.getBody(), StandardCharsets.UTF_8);
//
//		try {
//			SSGLMqBaseRequest request = JSON.parseObject(processMessage, SSGLMqBaseRequest.class);
//			if (SSGLMqTypeEnum.NEW_PERSONINFO.getValue().equals(request.getType())) {
//				SSGLNewPersonInfoRequest ssglNewPersonInfoRequest = JSON.parseObject(request.getMessage(), SSGLNewPersonInfoRequest.class);
//				exposeClientService.ssglNewPersonInfo(ssglNewPersonInfoRequest);
//			} else if (SSGLMqTypeEnum.ACCESS_RECORD.getValue().equals(request.getType())) {
//				SSGLAccessRecordRequest accessRecordRequest = JSON.parseObject(request.getMessage(), SSGLAccessRecordRequest.class);
//				exposeClientService.ssglAccessRecord(accessRecordRequest);
//			}
//		} catch (Exception e) {
//			logger.info("KitchenPrinter-出现异常队列消息开始进入死信队列{{}}",e);
//		}
//
//		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
//	}
//
//	/**
//	 * 把该监听命名为B监听
//	 * 监听死信队列  远程服务支付接口发送消息  该队列会接受
//	 * [message, headers, channel]
//	 * @return {@link }
//	 * @throws
//	 */
//	@RabbitListener(queues =  KitchenPrinterMqConfig.KITCHENPRINTER_DIE_QUEUE)
//	public void processForDie(Message message, @Headers Map<String, Object> headers, Channel channel) throws Exception {
//		//死信队列放弃
//		channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);
//		logger.info("KitchenPrinter-死信队列放弃 ， 【{}】",message);
//	}
//
//
//}
